layui.define(['table', 'form', 'element'], function(exports){
  var $ = layui.$,table = layui.table,form = layui.form, element = layui.element;

  var userId = $('input[name="userId"]').val();

    table.render({
        elem: '#LAY-table'
        ,url: layui.setter.webRoot + '/agent/place/list.data'
        ,where:{userId:userId}
        ,method: 'post'
        ,parseData: function (res) {
            return {
                "code": res.code,
                "msg": res.msg,
                "count": res.body.total,
                "data": res.body.data
            };
        }
        ,response: {statusCode: 200}
        ,cols: [[
            {field: 'id', title: '网点ID',width:80}
            ,{field: 'name', title: '网点名称'}
			,{field: 'typeNames', title: '网点类型'}
            ,{field: 'userCount', title: '用户数量',width:100}
            ,{field: 'deviceCount', title: '设备数量',width:100}
            ,{field: 'areaName', title: '所在区域'}
            ,{field: 'stateName', title:'状态',width:80}
            ,{field: 'createDate', title: '创建时间'}
        ]]
        ,page: true
        ,limit: 30
        ,height: 'full-220'
        ,text: '对不起，加载出现异常！'
    });

    //事件
    var active = {
       
    }

    $('.layui-btn.LAY-btn-fun').on('click', function(){
        var type = $(this).data('type');
        active[type] ? active[type].call(this) : '';
    });

    table.on('tool(LAY-table-func-model)', function(obj){
        var type = obj.event ;
        active[type] ? active[type].call(this,obj) : '';
    });

  exports('agent_place_list', {})
});